package com.wokeMy.view.adpter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.zhongcai.online.R;

import java.util.ArrayList;

/**
 * Created by Administrator on 2018/2/6 0006.
 */

public class HorLvAdapter extends BaseAdapter {
    private LayoutInflater inflater;
    ArrayList<String> data;
    private String qsize; //前区的个数
    private String lotteryId; //前区的个数
    private Context context;
     public HorLvAdapter(Context context, ArrayList<String> data,String qsize,String lotteryId) {
        this.inflater = LayoutInflater.from(context);
        this.context=context;
        this.data=data;
        this.qsize =qsize;
        this.lotteryId =lotteryId;
    }




    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHold viewHold;
        if (convertView==null){
            viewHold=new ViewHold();
            convertView=inflater.inflate(R.layout.item_item_ball_hrlv,null);
            viewHold.tvBall=(TextView)convertView.findViewById(R.id.ball_item_item_tv_hlv);
            viewHold.tvOther=(TextView)convertView.findViewById(R.id.sum_item_item_tv_hlv);
            convertView.setTag(viewHold);
        }else {
            viewHold=(ViewHold)convertView.getTag();
        }
        if (lotteryId.equals("123")){
            //赢快3
            viewHold.tvBall.setVisibility(View.GONE);
            viewHold.tvOther.setTextColor(context.getResources().getColor(R.color.gray));
            viewHold.tvOther.setVisibility(View.VISIBLE);
            if (data.get(position).equals("1*2*3*4*5*6")){
                viewHold.tvOther.setText("111 222 333 444 555 666");
            }else {
                viewHold.tvOther.setText(data.get(position)+"");
            }
        }else{
            if (position>(Integer.valueOf(qsize)-1)){
                viewHold.tvBall.setBackgroundResource(R.mipmap.blue_ball_bg);
            }else {
                viewHold.tvBall.setBackgroundResource(R.mipmap.red_ball_bg);
            }
            viewHold.tvBall.setTextColor(context.getResources().getColor(R.color.white));
            viewHold.tvBall.setText(data.get(position)+"");
        }


        return convertView;
    }
    class ViewHold {
        TextView tvBall;
        TextView tvOther;
    }
}
